<?

function printImage($id, $name, $size)
{
    $image = wp_get_attachment_image_src($id, $size);
    if (get_field('image_1')) {
        ?>
    <img style="margin-bottom:15px; border-radius:3px;" src="<?php echo $image[0]; ?>"
         alt="<?php echo $name ?>" title="<?php echo $name ?>"/>
    <?php } else { ?>
    <img style="margin-bottom:15px; border-radius:3px;"
         src="<?php echo get_template_directory_uri(); ?>/img/backup.png"
         alt="<?php echo $name ?>"/>
    <?php
    }
}

function getImageURL($id, $size)
{
    $image = wp_get_attachment_image_src($id, $size);
    if (get_field('image_1')) {
        echo $image[0];
    } else {
        echo get_template_directory_uri().'/img/backup.png';
    }
}

function getVenueID($id)
{
    $type = get_post_type($id);

    if ($type == 'pitch') {
        $venueID = get_field('venue', $id);
    }

    if ($type == 'slot') {
        $pitchID = get_field('pitch', $id);
        $venueID = get_field('venue', $pitchID);
    }

    if ($type == 'booking' || $type == 'special') {
        $slotID = get_field('slot', $id);
        $pitchID = get_field('pitch', $slotID);
        $venueID = get_field('venue', $pitchID);
    }

    return $venueID;
}

function getPitchID($id)
{
    $type = get_post_type($id);

    if ($type == 'slot') {
        $pitchID = get_field('pitch', $id);
    }

    if ($type == 'booking' || $type == 'special') {
        $slotID = get_field('slot', $id);
        $pitchID = get_field('pitch', $slotID);
    }

    return $pitchID;
}

function getSlotID($id)
{
    $type = get_post_type($id);

    if ($type == 'booking' || $type == 'special') {
        $slotID = get_field('slot', $id);
    }

    return $slotID;
}

function dp2($number)
{

    return str_pad($number, 2, "0", STR_PAD_LEFT);
}